//
//  JobViewController.m
//  Btpin
//
//  Created by Vic on 2019/3/10.
//  Copyright © 2019 Vic. All rights reserved.
//


#import "CompanyHomeViewController.h"
#import "WorkerCell.h"
#import "CompanyHomeHeaderView.h"
#import "HomePulldownView.h"
#import "HomeCustomNavigationBarView.h"
//#import "SearchJobCompanyViewController.h"
#import "SearchWorkerViewController.h"
#import "JobDetailViewController.h"

#import "WorkerResumeDetailViewController.h"
#import "SelcetCityViewController.h"
#import "PMineInviteFriendViewController.h"
//#import "NewsViewController.h"
#import "GeneralWebViewViewController.h"

#import "LYRecomendCell.h"

#import "WorkerModel.h"
#import "CompanyJobModel.h"
#import "SelectJobViewController.h"
#import "CompanyInfoViewController.h"
#import "QRCodeViewController.h"
#import "AppDelegate.h"
#import "WorkerCollectionViewCell.h"

#import "HomeBallHeaderView.h"
#import "LYStackLayout.h"
#import "PMineBusinessCardViewController.h"
#import "CTransitionToResumeDetailVC.h"
#import "CHomeFilterView.h"

@interface CompanyHomeViewController ()<CompanyHomeHeaderViewDelegate, UIScrollViewDelegate, HomeCustomNavigationBarViewDelegate, SelcetCityViewControllerDelegate, HomeBallHeaderViewDelegate, UICollectionViewDelegate, UICollectionViewDataSource, UICollectionViewDelegateFlowLayout, UINavigationControllerDelegate, CHomeFilterViewDelegate>
{
    NSMutableArray *itemDataArray;
    NSMutableArray *ballDataArray;
    CGFloat offsetY;
    
    HomeBallHeaderView *headerBallView;
    
    HomeCustomNavigationBarView *navigationBar;
    CompanyHomeHeaderView *tableViewHeaderView;
    NSInteger currentPage;
    
    NSString *recommend;
    NSString *district;
    NSString *experience;
    NSString *minwage;
    NSString *maxwage;
    NSString *wage;
    NSString *keyword;
    NSString *lat;
    NSString *lng;
    NSString *education;
    NSString *nature;
    
    NSString *job_id;
    NSString *job_title;
    
    UIView *baseBgView;
    
    CHomeFilterView *CHFView;
}
@end

@implementation CompanyHomeViewController

- (void)viewWillAppear:(BOOL)animated {
    [super viewWillAppear:animated];
    [self.navigationController setNavigationBarHidden:YES animated:YES];
//    if (offsetY == 0) {
//        [UIApplication sharedApplication].statusBarStyle = UIStatusBarStyleLightContent;
//    } else {
//        [UIApplication sharedApplication].statusBarStyle = UIStatusBarStyleDefault;
//    }
    [UIApplication sharedApplication].statusBarStyle = UIStatusBarStyleDefault;
}
- (void)viewWillDisappear:(BOOL)animated {
    [super viewWillDisappear:animated];
    [UIApplication sharedApplication].statusBarStyle = UIStatusBarStyleDefault;
//    if (self.navigationController.delegate == self) {
//        self.navigationController.delegate = nil;
//    }
    
    if (CHFView && CHFView.filterShowFlag) {
        [CHFView dismissView];
    }
}
- (void)viewDidAppear:(BOOL)animated {
    [super viewDidAppear:animated];
    self.navigationController.delegate = self;
}
- (void)dealloc {
    [[NSNotificationCenter defaultCenter] removeObserver:self];
}
- (void)viewDidLoad {
    [super viewDidLoad];
    
    [[NSNotificationCenter defaultCenter]addObserver:self selector:@selector(loadDataAndToTop) name:NotificationForCompanyResumeRefresh object:nil];
    
    itemDataArray = [NSMutableArray arrayWithCapacity:0];
    ballDataArray = [NSMutableArray arrayWithCapacity:0];
    offsetY = 0;
    
    currentPage = 1;
    recommend = @"";
    district = @"";
    experience = @"";
//    minwage = @"";
//    maxwage = @"";
    wage = @"0";
    keyword = @"";
    lat = @"";
    lng = @"";
    nature = @"";
    education = @"";
    job_id = @"";
    job_title = @"";
    
    
//    [self loadDataForJobList];
    
//    [self initUI];
//    [self getCompanyList];
    
    if ([DataToolsControl sharedManager].companyBaseInfoModel && [DataToolsControl sharedManager].companyBaseInfoModel.userinfo.name.length) {
        if ((([DataToolsControl sharedManager].companyBaseInfoModel && [DataToolsControl sharedManager].companyBaseInfoModel.audit.length) && ([[DataToolsControl sharedManager].companyBaseInfoModel.audit integerValue]==1))) {
            [self loadDataForJobList];
        } else {
            [self baseInitUI];
        }
    } else {
        [self loadDataBaseData];
    }
}
- (void)loadDataBaseData {
    self.noDataView.hidden = YES;
    SVPHUDShow;
    NSMutableDictionary *dic = [NSMutableDictionary dictionaryWithCapacity:0];
    dic = [UIToolsControl getPublicParameter];
    [BaseNetManager requestWithMethod:POST path:Company_GetBaseInfo_URL params:dic successBlock:^(NSDictionary *responseObject) {
        if ([responseObject[@"code"] integerValue] == 2000) {
            [DataToolsControl dataAnalysisUserBaseInfoForCompany:responseObject];
            [DataToolsControl sharedManager].companyBaseInfoModel = [[CompanyBaseInfoModel alloc] init];
            [[DataToolsControl sharedManager].companyBaseInfoModel setValuesForKeysWithDictionary:responseObject[@"data"]];
            if ((([DataToolsControl sharedManager].companyBaseInfoModel && [DataToolsControl sharedManager].companyBaseInfoModel.audit.length) && ([[DataToolsControl sharedManager].companyBaseInfoModel.audit integerValue]==1))) {
                [self loadDataForJobList];
            } else {
                [self baseInitUI];
            }
            SVPHUDDismiss;
        } else {
            SVPHUDError(responseObject[@"msg"]);
        }
    } failurBlock:^(NSError *error) {
        SVPHUDError(NetErrorAlertText);
        [self.noDataView vcNilStatusType:VCNilStatusTypeOfNoNet superView:self.view];
    }];
}
- (void)noNetButtonTap {
//    [self loadDataForJobList];
    [self loadDataBaseData];
}
- (void)loadDataAndToTop {
    if (self.cCollectionView) {
        currentPage = 1;
        if (self.cCollectionView.contentOffset.y !=0) {
            [self.cCollectionView setContentOffset:CGPointMake(0, 0) animated:YES];
        }
        [self getCompanyList];
    } else {
        [self loadDataForJobList];
    }
}
- (void)getCompanyList {
    self.noDataView.hidden = YES;
    SVPHUDShow;
    NSMutableDictionary *dic = [NSMutableDictionary dictionaryWithCapacity:0];
    dic = [UIToolsControl getPublicParameter];
    [dic setObject:recommend forKey:@"recommend"];
    [dic setObject:district forKey:@"district"];
    [dic setObject:experience forKey:@"experience"];
//    [dic setObject:minwage forKey:@"minwage"];
//    [dic setObject:maxwage forKey:@"maxwage"];
    [dic setObject:wage forKey:@"wage"];
    [dic setObject:keyword forKey:@"keyword"];
    [dic setObject:lat forKey:@"lat"];
    [dic setObject:lng forKey:@"lng"];
    [dic setObject:nature forKey:@"nature"];
    [dic setObject:education forKey:@"education"];
    [dic setObject:[NSString stringWithFormat:@"%ld", (long)currentPage] forKey:@"page"];
    [dic setObject:PageSize forKey:@"number"];
    [dic setObject:job_id forKey:@"job_id"];
    
    [BaseNetManager requestWithMethod:POST path:ResumeGetLists_URL params:dic successBlock:^(NSDictionary *responseObject) {
        if ([responseObject[@"code"] integerValue] == 2000) {
            id data = responseObject[@"data"];
            if ([data isKindOfClass:[NSArray class]]) {
                if (self->currentPage == 1) {
                    if (self->itemDataArray.count) {
                        [self->itemDataArray removeAllObjects];
                    }
                }
                for (NSDictionary *dic in data) {
                    WorkerModel *model = [[WorkerModel alloc] init];
                    [model setValuesForKeysWithDictionary:dic];
                    model.auth_info = dic[@"auth_info"];
                    model.type = WorkerCellTypeOfOnlyTime;
                    [self->itemDataArray addObject:model];
                }
                self.noDataView.hidden = YES;
                [self.cCollectionView.mj_footer endRefreshing];
                [self.cCollectionView reloadData];
            }
            if (self->itemDataArray.count) {
            } else {
                self.noDataView.hidden = NO;
                [self.noDataView vcNilStatusType:VCNilStatusTypeOfWorkerList superView:self.view];
            }
            SVPHUDDismiss;
        } else {
            NSString *str = [NSString stringWithFormat:@"%@", responseObject[@"msg"]];
            SVPHUDError(str);
        }
    } failurBlock:^(NSError *error) {
        SVPHUDError(NetErrorAlertText);
        [self.noDataView vcNilStatusType:VCNilStatusTypeOfNoNet superView:self.view];
    }];
}
- (NSMutableArray *)loadCategoryForBall {
    for (PublicCategoryElementModel *tempMpdel in [DataToolsControl sharedManager].allCategoryInfoModel.jobCatsArrayForOneLevel) {
        if (tempMpdel.jobCatsArrayForTworThreeLevel.count) {
            for (PublicCategoryElementModel *tempMpdel111 in tempMpdel.jobCatsArrayForTworThreeLevel) {
                
                BOOL addFlag = YES;
                for (PublicCategoryElementModel *guolvModel in ballDataArray) {
                    if ([guolvModel.name isEqualToString:tempMpdel111.name]) {
                        addFlag = NO;
                        break;
                    }
                }
                if (addFlag) {
                    [ballDataArray addObject:[tempMpdel111 copy]];
                }
            }
        }
    }
    return ballDataArray;
}
- (void)initUI {
    self.view.backgroundColor = THEMECOLOR_OF_GRAY;
    CGRect frame = self.noDataView.frame;
    frame.origin.y += 450*Scale;
    self.noDataView.frame = frame;
    
    NSMutableArray *ballArray = [NSMutableArray arrayWithCapacity:0];
    ballArray = [self loadCategoryForBall];
    
    headerBallView = [[HomeBallHeaderView alloc] initWithFrame:CGRectMake(0, 0, WIDTH, ScalePS(460)) dataArray:ballArray target:self idType:TabBarTypeOfCompany];
    headerBallView.userInteractionEnabled = YES;
    [headerBallView reloadDataForJob:job_title];
    
    LYStackLayout *layout = [[LYStackLayout alloc]init];
    //卡片的边界设置
    layout.layoutMargin =  UIEdgeInsetsMake(10.0, 0.0, 0.0, 0.0);
    //卡片大小
    layout.itemCellSize = CGSizeMake(WIDTH, ScalePS(130));
    //两个卡片间的距离
    layout.topReveal = ScalePS(90.0);
    //头视图高度
    layout.headerHeight = ScalePS(460);
    self.cCollectionView = [[UICollectionView alloc] initWithFrame:CGRectMake(0, HeightOfStatusBarAndNavigationBar, WIDTH, HEIGHT-HeightOfTabBar-HeightOfStatusBarAndNavigationBar) collectionViewLayout:layout];
//    self.cCollectionView.backgroundColor = COLOR_OF_CLEAR;
    self.cCollectionView.backgroundColor = COLOR_OF_WHITE;
    self.cCollectionView.showsHorizontalScrollIndicator = NO;
    self.cCollectionView.showsVerticalScrollIndicator = NO;
    self.cCollectionView.delegate = self;
    self.cCollectionView.dataSource = self;
    [self.view addSubview:self.cCollectionView];
    
    [self.cCollectionView registerClass:[WorkerCollectionViewCell class] forCellWithReuseIdentifier:isCellID];
    
    [self.cCollectionView addSubview:headerBallView];
//    self.cCollectionView.contentInset = UIEdgeInsetsMake(0, 0, ScalePS(434), 0);
    
    if (@available(iOS 11.0, *)) {
        self.cCollectionView.contentInsetAdjustmentBehavior = UIScrollViewContentInsetAdjustmentNever;
    } else {
        self.automaticallyAdjustsScrollViewInsets = NO;
    }
    __weak __typeof(self)weakSelf = self;
    self.cCollectionView.mj_footer = [MJRefreshAutoFooter footerWithRefreshingBlock:^{
        self->currentPage++;
        [weakSelf.cCollectionView.mj_footer beginRefreshing];
        dispatch_after(dispatch_time(DISPATCH_TIME_NOW, (int64_t)(MJDuration * NSEC_PER_SEC)), dispatch_get_main_queue(), ^{
            [weakSelf getCompanyList];
        });
    }];
    
    navigationBar = [[HomeCustomNavigationBarView alloc] initWithFrame:CGRectMake(0, 0, WIDTH, HeightOfStatusBarAndNavigationBar) target:self];
    navigationBar.offsetY = 0;
    [self.view addSubview:navigationBar];
    
    CHFView = [[CHomeFilterView alloc] initWithFrame:CGRectMake(WIDTH, 0, WIDTH, HEIGHT) target:self];
    [[UIApplication sharedApplication].keyWindow addSubview:CHFView];
}
#pragma mark -- UICollectionViewDataSource
- (NSInteger)collectionView:(UICollectionView *)collectionView numberOfItemsInSection:(NSInteger)section {
    return  itemDataArray.count;
}
- (UICollectionViewCell *)collectionView:(UICollectionView *)collectionView cellForItemAtIndexPath:(NSIndexPath *)indexPath {
    WorkerCollectionViewCell *cell = [collectionView dequeueReusableCellWithReuseIdentifier:isCellID forIndexPath:indexPath];
    
    WorkerModel *model = itemDataArray[indexPath.row];
    [cell reloadDataModel:model indexPath:indexPath];
    
    return cell;
}
#pragma mark -- UICollectionViewDelegateFlowLayout
- (void)collectionView:(UICollectionView *)collectionView didSelectItemAtIndexPath:(NSIndexPath *)indexPath {
    self.selectedIndexPath = indexPath;
    
    UIColor *bgColor = THEMECOLOR_OF_ORANGE;
//    switch (indexPath.row%5) {
//        case 0: {
//            bgColor = RGB(255, 118, 108);
//        } break;
//        case 1: {
//            bgColor = RGB(187, 104, 252);
//        } break;
//        case 2: {
//            bgColor = RGB(255, 137, 67);
//        } break;
//        case 3: {
//            bgColor = RGB(2, 168, 252);
//        } break;
//        case 4: {
//            bgColor = RGB(254, 187, 57);
//        } break;
//        default:
//            break;
//    }
    
    if ([DataToolsControl sharedManager].validJob) {
        WorkerModel *model = itemDataArray[indexPath.row];
        WorkerResumeDetailViewController *WRDVC = [[WorkerResumeDetailViewController alloc] init];
        WRDVC.job_id = job_id;
        WRDVC.job_cn = job_title;
        WRDVC.id = model.id;
        WRDVC.bgColor = bgColor;
        WRDVC.showChatSettingFlag = NO;
        WRDVC.hidesBottomBarWhenPushed = YES;
        [self.navigationController pushViewController:WRDVC animated:YES];
    } else {
        [self jumpCompanyAudit];
    }
}
#pragma mark UINavigationControllerDelegate methods
//- (id<UIViewControllerAnimatedTransitioning>)navigationController:(UINavigationController *)navigationController animationControllerForOperation:(UINavigationControllerOperation)operation fromViewController:(UIViewController *)fromVC toViewController:(UIViewController *)toVC {
//    if ([fromVC isKindOfClass:[CompanyHomeViewController class]] && [toVC isKindOfClass:[WorkerResumeDetailViewController class]]) {
//        CTransitionToResumeDetailVC *transitionVC = [[CTransitionToResumeDetailVC alloc] init];
//        return transitionVC;
//    } else {
//        return nil;
//    }
//}


- (void)homeCustomNavigationBarViewFilter {
    if (CHFView.filterShowFlag) {
        [CHFView dismissView];
    } else {
        [CHFView showView];
    }
}
- (void)homeCustomNavigationBarViewQRCode {
    if (Signin) {
        QRCodeViewController *QRCVC = [[QRCodeViewController alloc] init];
        QRCVC.pushVCType = VCPushTypeOfHome;
        QRCVC.edit = ^(BOOL editFlag) {
            
        };
        QRCVC.hidesBottomBarWhenPushed = YES;
        [self.navigationController pushViewController:QRCVC animated:YES];
    } else {
        [UIToolsControl presentSignin:self callBack:^(BOOL signinFlag) {
            
        }];
    }
}
- (void)homeBallHeaderViewTap:(HomeLinkType)homeLinkType {
    switch (homeLinkType) {
        case HomeLinkTypeOfJobPromotion: {
            GeneralWebViewViewController *GWVC = [[GeneralWebViewViewController alloc] init];
            GWVC.showType = GeneralWebViewTypeOfGeneralize;
            GWVC.hidesBottomBarWhenPushed = YES;
            [self.navigationController pushViewController:GWVC animated:YES];
        } break;
        case HomeLinkTypeOfBusinessCard: {
            PMineBusinessCardViewController *PMBCVC = [[PMineBusinessCardViewController alloc] init];
            PMBCVC.hidesBottomBarWhenPushed = YES;
            [self.navigationController pushViewController:PMBCVC animated:YES];
        } break;
        case HomeLinkTypeOfInvite: {
            GeneralWebViewViewController *GWVC = [[GeneralWebViewViewController alloc] init];
            GWVC.showType = GeneralWebViewTypeOfInviteFriend;
            GWVC.hidesBottomBarWhenPushed = YES;
            [self.navigationController pushViewController:GWVC animated:YES];
        } break;
        default:
            break;
    }
}
- (void)homeBallHeaderViewBallPointTap:(NSString *)pointId pointText:(nonnull NSString *)pointText {
    if (![job_id isEqualToString:pointId]) {
        job_id = pointId;
        job_title = pointText;
        [headerBallView reloadDataForJob:pointText];
        currentPage = 1;
        [self getCompanyList];
    }
}
- (void)homeBallHeaderViewSelectJobTap {
    if ([DataToolsControl sharedManager].validJob) {
        SelectJobViewController *SJVC = [[SelectJobViewController alloc] init];
        SJVC.jobIdSelect = job_id;
        __weak __typeof(self)weakSelf = self;
        SJVC.select = ^(NSString *jobId, NSString *jobTitle) {
            __strong __typeof(weakSelf)strongSelf = weakSelf;
            if (jobId && jobId.length) {
                self->job_id = jobId;
                self->job_title = jobTitle;
//                [self->tableViewHeaderView reloadDataForJob:jobTitle];
                [self->headerBallView reloadDataForJob:jobTitle];
                self->currentPage = 1;
                [self->itemDataArray removeAllObjects];
                [strongSelf getCompanyList];
            }
        };
        SJVC.hidesBottomBarWhenPushed = YES;
        [self.navigationController pushViewController:SJVC animated:YES];
    } else {
        [self jumpCompanyAudit];
    }
}

- (void)dropDownViewTapBack {
    self.noDataView.hidden = YES;
    [self.cCollectionView setContentOffset:CGPointMake(0, 325*Scale) animated:YES];
}

- (void)homeCustomNavigationBarViewCity {
    NSLog(@"city");
    SelcetCityViewController *SCVC = [[SelcetCityViewController alloc] init];
    SCVC.hidesBottomBarWhenPushed = YES;
    SCVC.delegate = self;
    [self.navigationController pushViewController:SCVC animated:YES];
}
- (void)selcetCityViewControllerInfo:(NSDictionary *)dic {
    if (district && (![district isEqualToString:[NSString stringWithFormat:@"%@", dic[@"cityid"]]])) {
        [itemDataArray removeAllObjects];
    }
    if ([[NSString stringWithFormat:@"%@", dic[@"cityid"]] integerValue] == 0) {
        district = [NSString stringWithFormat:@"%@", dic[@"provinceid"]];
        navigationBar.city = dic[@"province"];
    } else {
        district = [NSString stringWithFormat:@"%@", dic[@"cityid"]];
        navigationBar.city = dic[@"city"];
    }
    currentPage = 1;
    [self getCompanyList];
}
- (void)homeCustomNavigationBarViewSearch {
    NSLog(@"search");
    if (job_id && job_id.length) {
        SearchWorkerViewController *SWVC = [[SearchWorkerViewController alloc] init];
        SWVC.hidesBottomBarWhenPushed = YES;
        [self.navigationController pushViewController:SWVC animated:YES];
    } else {
        [self jumpCompanyAudit];
    }
}
- (void)jumpCompanyAudit {
    CustomView *alertView = [[CustomView alloc] initWithTitle:@"提示" message:@"您当前没有“审核通过”的职位，去发布职位" prompt:nil sureBtn:@"发布职位" cancleBtn:@"取消" size:170];
    alertView.resultIndex = ^(NSInteger index){
        //回调---处理一系列动作
        if (index == 2) {
            [self gotoCreatJob];
        }
    };
    [alertView showXLAlertView];
}
- (void)companyHomeHeaderViewBannerCarouselTap:(NSString *)temp {
    NSLog(@"%@", temp);
}
- (void)companyHomeHeaderViewNewCarouselTap:(ArticleItemModel *)model {
    NSLog(@"new轮播");
    if (model && model.url) {
        GeneralWebViewViewController *GWVC = [[GeneralWebViewViewController alloc] init];
        GWVC.url = model.url;
        GWVC.showType = GeneralWebViewTypeOfNews;
        GWVC.hidesBottomBarWhenPushed = YES;
        [self.navigationController pushViewController:GWVC animated:YES];
    }
}
- (void)cHomeFilterViewBaseInfoOkWage:(NSString *)wage1 experience:(NSString *)experience1 education:(NSString *)education1 {
    if (wage1 && wage1.length) {
        if (wage && (![wage isEqualToString:wage1])) {
            if (itemDataArray.count) {
                [itemDataArray removeAllObjects];
            }
            wage = wage1;
        }
    }
    if (experience1 && experience1.length) {
        if (experience && (![experience isEqualToString:experience1])) {
            if (itemDataArray.count) {
                [itemDataArray removeAllObjects];
            }
            experience = experience1;
        }
    }
    if (education1 && education1.length) {
        if (education && (![education isEqualToString:education1])) {
            if (itemDataArray.count) {
                [itemDataArray removeAllObjects];
            }
            education = education1;
        }
    }
    
    if (itemDataArray.count) {
        
    } else {
        currentPage = 1;
        [self getCompanyList];
    }
}
- (void)hiddenNoDataView {
    if (itemDataArray.count) {
        self.noDataView.hidden = YES;
    } else {
        self.noDataView.hidden = NO;
    }
}
- (void)companyHomeHeaderViewNewInvitationTap {
    GeneralWebViewViewController *GWVC = [[GeneralWebViewViewController alloc] init];
    GWVC.showType = GeneralWebViewTypeOfInviteFriend;
    GWVC.hidesBottomBarWhenPushed = YES;
    [self.navigationController pushViewController:GWVC animated:YES];
}
//- (void)companyHomeHeaderViewSelectJobTap {
//    if ([DataToolsControl sharedManager].validJob) {
//        SelectJobViewController *SJVC = [[SelectJobViewController alloc] init];
//        __weak __typeof(self)weakSelf = self;
//        SJVC.select = ^(NSString *jobId, NSString *jobTitle) {
//            __strong __typeof(weakSelf)strongSelf = weakSelf;
//            if (jobId && jobId.length) {
//                self->job_id = jobId;
//                self->job_title = jobTitle;
//                [self->tableViewHeaderView reloadDataForJob:jobTitle];
//                self->currentPage = 1;
//                [self->itemDataArray removeAllObjects];
//                [strongSelf getCompanyList];
//            }
//        };
//        SJVC.hidesBottomBarWhenPushed = YES;
//        [self.navigationController pushViewController:SJVC animated:YES];
//    } else {
//        [self jumpCompanyAudit];
//    }
//}
- (void)scrollViewDidScroll:(UIScrollView *)scrollView {
    if (scrollView == self.cCollectionView) {
        navigationBar.offsetY = scrollView.contentOffset.y;
        offsetY = scrollView.contentOffset.y;
    }
}
- (void)loadDataForJobList {
    self.noDataView.hidden = YES;
    NSMutableDictionary *dic = [NSMutableDictionary dictionaryWithCapacity:0];
    dic = [UIToolsControl getPublicParameter];
    [dic setObject:@"1" forKey:@"status"];
    [dic setObject:@"1" forKey:@"page"];
    [dic setObject:PageSize forKey:@"number"];
    
    [BaseNetManager requestWithMethod:POST path:Company_GetJob_Lists_URL params:dic successBlock:^(NSDictionary * _Nonnull responseObject) {
        if ([responseObject[@"code"] integerValue] == 2000) {
            id data = responseObject[@"data"];
            if ([data isKindOfClass:[NSArray class]]) {
                if ([data count]) {
                    [DataToolsControl sharedManager].validJob = YES;
                    NSDictionary *dicc = data[0];
                    CompanyJobModel *model = [[CompanyJobModel alloc] init];
                    [model setValuesForKeysWithDictionary:dicc];
                    self->job_id = model.id;
                    self->job_title = model.title;
                    
                    for (NSDictionary *dic111 in data) {
                        CompanyJobModel *tempModel = [[CompanyJobModel alloc] init];
                        [tempModel setValuesForKeysWithDictionary:dic111];
                        PublicCategoryElementModel *ballModel = [[PublicCategoryElementModel alloc] init];
                        ballModel.name = tempModel.title;
                        ballModel.id = tempModel.id;
                        ballModel.canTapFlag = YES;
                        [self->ballDataArray addObject:ballModel];
                    }
                    
                    [self initUI];
                    [self getCompanyList];
                } else {
                    [DataToolsControl sharedManager].validJob = NO;
                    self->job_id = @"";
                    self->job_title = @"";
                    
                    [self initUI];
                    [self getCompanyList];
                }
            } else {
                [DataToolsControl sharedManager].validJob = NO;
                self->job_id = @"";
                self->job_title = @"";
                
                [self initUI];
                [self getCompanyList];
            }
        } else {
            [DataToolsControl sharedManager].validJob = NO;
            self->job_id = @"";
            self->job_title = @"";
            
            [self initUI];
            [self getCompanyList];
        }
    } failurBlock:^(NSError * _Nonnull error) {
        [self.noDataView vcNilStatusType:VCNilStatusTypeOfNoNet superView:self.view];
    }];
}
- (void)baseInitUI {
    if (!baseBgView) {
        baseBgView = [UIToolsControl initViewWithFrame:CGRectMake(0, HeightOfStatusBarAndNavigationBar, WIDTH, HEIGHT) backgroundColor:COLOR_OF_WHITE];
        [self.view addSubview:baseBgView];
        
        UILabel *topLbl = [UIToolsControl initLabelWithFrame:CGRectMake(0, 100*Scale, WIDTH, 40*Scale) text:@"您未完成企业认证，不能查看人才" textColor:THEMECOLOR_OF_TEXT_333333 font:Font_21];
        topLbl.textAlignment = NSTextAlignmentCenter;
        [baseBgView addSubview:topLbl];
        
        UIImageView *imgView = [UIToolsControl initImageViewWithFrame:CGRectMake(110*Scale, EndY(topLbl)+40*Scale, WIDTH-220*Scale, 120*Scale) imageName:@"qiyerenzheng-panduan"];
        [baseBgView addSubview:imgView];
        
        UILabel *bottomLbl = [UIToolsControl initLabelWithFrame:CGRectMake(0, EndY(imgView), WIDTH, 45*Scale) text:@"企业公司营业执照" textColor:THEMECOLOR_OF_TEXT_9a9a9a font:Font_13];
        bottomLbl.textAlignment = NSTextAlignmentCenter;
        [baseBgView addSubview:bottomLbl];
        
        UIButton *gotoBtn = [UIToolsControl initButtonWithFrame:CGRectMake(40*Scale, EndY(bottomLbl)+30*Scale, WIDTH-80*Scale, 50*Scale) imageName:nil target:self action:@selector(gotoBtnTap) title:@"立刻去完善认证" titleColor:COLOR_OF_WHITE];
        gotoBtn.layer.cornerRadius = 25*Scale;
        gotoBtn.layer.masksToBounds = YES;
        gotoBtn.backgroundColor = THEMECOLOR_OF_ORANGE;
        [baseBgView addSubview:gotoBtn];
    }
}
- (void)gotoBtnTap {
    if (Signin) {
        UITabBarController *tabBarController = (UITabBarController *)[UIApplication sharedApplication].keyWindow.rootViewController;
        tabBarController.selectedIndex = tabBarController.viewControllers.count-1;
        UINavigationController *navigationController = (UINavigationController *)tabBarController.selectedViewController;
        CompanyInfoViewController *CIVC = [[CompanyInfoViewController alloc] init];
        CIVC.hidesBottomBarWhenPushed = YES;
        [navigationController pushViewController:CIVC animated:NO];
    } else {
        [UIToolsControl presentSignin:self callBack:^(BOOL signinFlag) {
            
        }];
    }
}
- (void)gotoCreatJob {
    if (Signin) {
        UITabBarController *tabBarController = (UITabBarController *)[UIApplication sharedApplication].keyWindow.rootViewController;
        tabBarController.selectedIndex = 1;
//        UINavigationController *navigationController = (UINavigationController *)tabBarController.selectedViewController;
//        CompanyInfoViewController *CIVC = [[CompanyInfoViewController alloc] init];
//        CIVC.hidesBottomBarWhenPushed = YES;
//        [navigationController pushViewController:CIVC animated:NO];
    } else {
        [UIToolsControl presentSignin:self callBack:^(BOOL signinFlag) {
            
        }];
    }
}

@end












/*
#import "CompanyHomeViewController.h"
#import "WorkerCell.h"
#import "CompanyHomeHeaderView.h"
#import "HomePulldownView.h"
#import "HomeCustomNavigationBarView.h"
//#import "SearchJobCompanyViewController.h"
#import "SearchWorkerViewController.h"
#import "JobDetailViewController.h"

#import "WorkerResumeDetailViewController.h"
#import "SelcetCityViewController.h"
#import "PMineInviteFriendViewController.h"
//#import "NewsViewController.h"
#import "GeneralWebViewViewController.h"

#import "LYRecomendCell.h"
#import "LYDropDownView.h"

#import "LYRecomendView.h"
#import "LYCompanyView.h"
//#import "LYAreaView.h"
#import "PSAreaView.h"
#import "LYClaimView.h"

#import "WorkerModel.h"
#import "CompanyJobModel.h"
#import "SelectJobViewController.h"
#import "CompanyInfoViewController.h"
#import "QRCodeViewController.h"
#import "AppDelegate.h"

@interface CompanyHomeViewController ()<UITableViewDelegate, UITableViewDataSource, CompanyHomeHeaderViewDelegate, UIScrollViewDelegate, HomeCustomNavigationBarViewDelegate, SelcetCityViewControllerDelegate, LYDropDownViewDelegate>
{
    NSMutableArray *itemDataArray;
    CGFloat offsetY;
    
    NSMutableArray *recomendDataArray;
    NSMutableArray *areaDataArray;
    NSMutableArray *companyDataArray;
    NSMutableArray *claimDataArray;
    LYDropDownView *dropView;
    
    HomeCustomNavigationBarView *navigationBar;
    CompanyHomeHeaderView *tableViewHeaderView;
    NSInteger currentPage;
    
    NSString *recommend;
    NSString *district;
    NSString *experience;
    NSString *minwage;
    NSString *maxwage;
    NSString *wage;
    NSString *keyword;
    NSString *lat;
    NSString *lng;
    NSString *education;
    NSString *nature;
    
    NSString *job_id;
    NSString *job_title;
    
    UIView *baseBgView;
}
@property (nonatomic, strong) UITableView *jobTableView;
@end

@implementation CompanyHomeViewController

- (void)viewWillAppear:(BOOL)animated {
    [super viewWillAppear:animated];
    [self.navigationController setNavigationBarHidden:YES animated:YES];
    if (offsetY == 0) {
        [UIApplication sharedApplication].statusBarStyle = UIStatusBarStyleLightContent;
    } else {
        [UIApplication sharedApplication].statusBarStyle = UIStatusBarStyleDefault;
    }
}
- (void)viewWillDisappear:(BOOL)animated {
    [super viewWillDisappear:animated];
    [UIApplication sharedApplication].statusBarStyle = UIStatusBarStyleDefault;
}
- (void)dealloc {
    [[NSNotificationCenter defaultCenter] removeObserver:self];
}
- (void)viewDidLoad {
    [super viewDidLoad];
    
    [[NSNotificationCenter defaultCenter]addObserver:self selector:@selector(loadDataAndToTop) name:NotificationForCompanyResumeRefresh object:nil];
    
    itemDataArray = [NSMutableArray arrayWithCapacity:0];
    offsetY = 0;
    
    currentPage = 1;
    recommend = @"";
    district = @"";
    experience = @"";
//    minwage = @"";
//    maxwage = @"";
    wage = @"0";
    keyword = @"";
    lat = @"";
    lng = @"";
    nature = @"";
    education = @"";
    job_id = @"";
    job_title = @"";
    
    [self loadLocalData];
    
//    [self loadDataForJobList];
    
//    [self initUI];
//    [self getCompanyList];
    
    if ([DataToolsControl sharedManager].companyBaseInfoModel && [DataToolsControl sharedManager].companyBaseInfoModel.userinfo.name.length) {
        if ((([DataToolsControl sharedManager].companyBaseInfoModel && [DataToolsControl sharedManager].companyBaseInfoModel.audit.length) && ([[DataToolsControl sharedManager].companyBaseInfoModel.audit integerValue]==1))) {
            [self loadDataForJobList];
        } else {
            [self baseInitUI];
        }
    } else {
        [self loadDataBaseData];
    }
}
- (void)loadDataBaseData {
    self.noDataView.hidden = YES;
    SVPHUDShow;
    NSMutableDictionary *dic = [NSMutableDictionary dictionaryWithCapacity:0];
    dic = [UIToolsControl getPublicParameter];
    [BaseNetManager requestWithMethod:POST path:Company_GetBaseInfo_URL params:dic successBlock:^(NSDictionary *responseObject) {
        if ([responseObject[@"code"] integerValue] == 2000) {
            [DataToolsControl dataAnalysisUserBaseInfoForCompany:responseObject];
            [DataToolsControl sharedManager].companyBaseInfoModel = [[CompanyBaseInfoModel alloc] init];
            [[DataToolsControl sharedManager].companyBaseInfoModel setValuesForKeysWithDictionary:responseObject[@"data"]];
            if ((([DataToolsControl sharedManager].companyBaseInfoModel && [DataToolsControl sharedManager].companyBaseInfoModel.audit.length) && ([[DataToolsControl sharedManager].companyBaseInfoModel.audit integerValue]==1))) {
                [self loadDataForJobList];
            } else {
                [self baseInitUI];
            }
            SVPHUDDismiss;
        } else {
            SVPHUDError(responseObject[@"msg"]);
        }
    } failurBlock:^(NSError *error) {
        SVPHUDError(NetErrorAlertText);
        [self.noDataView vcNilStatusType:VCNilStatusTypeOfNoNet superView:self.view];
    }];
}
- (void)noNetButtonTap {
//    [self loadDataForJobList];
    [self loadDataBaseData];
}
- (void)loadDataAndToTop {
    if (self.jobTableView) {
        currentPage = 1;
        if (self.jobTableView.contentOffset.y !=0) {
            [self.jobTableView setContentOffset:CGPointMake(0, 0) animated:YES];
        }
        [self getCompanyList];
    } else {
        [self loadDataForJobList];
    }
}
- (void)getCompanyList {
    self.noDataView.hidden = YES;
    SVPHUDShow;
    NSMutableDictionary *dic = [NSMutableDictionary dictionaryWithCapacity:0];
    dic = [UIToolsControl getPublicParameter];
    [dic setObject:recommend forKey:@"recommend"];
    [dic setObject:district forKey:@"district"];
    [dic setObject:experience forKey:@"experience"];
//    [dic setObject:minwage forKey:@"minwage"];
//    [dic setObject:maxwage forKey:@"maxwage"];
    [dic setObject:wage forKey:@"wage"];
    [dic setObject:keyword forKey:@"keyword"];
    [dic setObject:lat forKey:@"lat"];
    [dic setObject:lng forKey:@"lng"];
    [dic setObject:nature forKey:@"nature"];
    [dic setObject:education forKey:@"education"];
    [dic setObject:[NSString stringWithFormat:@"%ld", (long)currentPage] forKey:@"page"];
    [dic setObject:PageSize forKey:@"number"];
    [dic setObject:job_id forKey:@"job_id"];
    
    [BaseNetManager requestWithMethod:POST path:ResumeGetLists_URL params:dic successBlock:^(NSDictionary *responseObject) {
        if ([responseObject[@"code"] integerValue] == 2000) {
            id data = responseObject[@"data"];
            if ([data isKindOfClass:[NSArray class]]) {
                if (self->currentPage == 1) {
                    if (self->itemDataArray.count) {
                        [self->itemDataArray removeAllObjects];
                    }
                }
                for (NSDictionary *dic in data) {
                    WorkerModel *model = [[WorkerModel alloc] init];
                    [model setValuesForKeysWithDictionary:dic];
                    model.auth_info = dic[@"auth_info"];
                    model.type = WorkerCellTypeOfOnlyTime;
                    [self->itemDataArray addObject:model];
                }
                self.noDataView.hidden = YES;
                [self.jobTableView.mj_footer endRefreshing];
                [self.jobTableView reloadData];
            }
            if (self->itemDataArray.count) {
            } else {
                self.noDataView.hidden = NO;
                [self.noDataView vcNilStatusType:VCNilStatusTypeOfWorkerList superView:self.view];
            }
            SVPHUDDismiss;
        } else {
            NSString *str = [NSString stringWithFormat:@"%@", responseObject[@"msg"]];
            SVPHUDError(str);
        }
    } failurBlock:^(NSError *error) {
        SVPHUDError(NetErrorAlertText);
        [self.noDataView vcNilStatusType:VCNilStatusTypeOfNoNet superView:self.view];
    }];
}
- (void)initUI {
    CGRect frame = self.noDataView.frame;
    frame.origin.y += 450*Scale;
    self.noDataView.frame = frame;
    
    self.jobTableView = [UIToolsControl initTableViewWithFrame:CGRectMake(0, 0, WIDTH, HEIGHT-HeightOfTabBar) target:self style:UITableViewStyleGrouped];
    self.jobTableView.separatorStyle = UITableViewCellSeparatorStyleNone;
    self.jobTableView.tableFooterView = [[UIView alloc] init];
    [self.view addSubview:self.jobTableView];
    if (@available(iOS 11.0, *)) {
        self.jobTableView.contentInsetAdjustmentBehavior = UIScrollViewContentInsetAdjustmentNever;
    } else {
        self.automaticallyAdjustsScrollViewInsets = NO;
    }
    __weak __typeof(self)weakSelf = self;
    self.jobTableView.mj_footer = [MJRefreshAutoFooter footerWithRefreshingBlock:^{
        self->currentPage++;
        [weakSelf.jobTableView.mj_footer beginRefreshing];
        dispatch_after(dispatch_time(DISPATCH_TIME_NOW, (int64_t)(MJDuration * NSEC_PER_SEC)), dispatch_get_main_queue(), ^{
            [weakSelf getCompanyList];
        });
    }];
    
    //头视图
    LYRecomendView *recommendVC = [[LYRecomendView alloc] initWithFrame:CGRectMake(0, 0, WIDTH, HEIGHT) data:recomendDataArray];
    recommendVC.backBlock = ^(PublicCategoryElementModel *model) {
        __strong __typeof(weakSelf)strongSelf = weakSelf;
        [strongSelf recomdendItemTap:model];
    };
    
    PSAreaView *areaVC = [[PSAreaView alloc] initWithFrame:CGRectMake(0, 0, WIDTH, HEIGHT) data:areaDataArray];
    areaVC.backBlcok = ^(NSDictionary * _Nullable dic) {
        __strong __typeof(weakSelf)strongSelf = weakSelf;
        [strongSelf areaItemTap:dic];
    };
    
    LYCompanyView *companyVC = [[LYCompanyView alloc] initWithFrame:CGRectMake(0, 0, WIDTH, HEIGHT) data:companyDataArray];
    companyVC.backBlock = ^(NSArray<PublicCategoryElementModel *> *array) {
        __strong __typeof(weakSelf)strongSelf = weakSelf;
        [strongSelf companyItemTap:array];
    };
    
    LYClaimView *claimVC = [[LYClaimView alloc] initWithFrame:CGRectMake(0, 0, WIDTH, HEIGHT) data:claimDataArray];
    claimVC.backBlock = ^(NSArray<PublicCategoryElementModel *> *array) {
        __strong __typeof(weakSelf)strongSelf = weakSelf;
        [strongSelf claimItemTap:array];
    };
    
    dropView = [[LYDropDownView alloc] initWithFrame:CGRectMake(0, 0, WIDTH, 44*Scale) titleArray:@[@"推荐", @"区域", @"经验", @"其他"] normalColor:THEMECOLOR_OF_TEXT_666666 selectColor:THEMECOLOR_OF_ORANGE normalImage:@"pulldown_unselect" selectImage:@"pulldown_select" dropViews:@[recommendVC, areaVC, companyVC, claimVC]];
    dropView.delegate = self;
    self.jobTableView.tableHeaderView = dropView;
    
    tableViewHeaderView = [[CompanyHomeHeaderView alloc] initWithFrame:CGRectMake(0, 0, WIDTH, 398*Scale+44*Scale) Target:self];
    tableViewHeaderView.backgroundColor = COLOR_OF_WHITE;
    dropView.headerView = tableViewHeaderView;
    [tableViewHeaderView reloadDataForJob:job_title];
    
    navigationBar = [[HomeCustomNavigationBarView alloc] initWithFrame:CGRectMake(0, 0, WIDTH, HeightOfStatusBarAndNavigationBar) target:self];
    navigationBar.offsetY = 0;
    [self.view addSubview:navigationBar];
}
- (void)homeCustomNavigationBarViewQRCode {
    if (Signin) {
        QRCodeViewController *QRCVC = [[QRCodeViewController alloc] init];
        QRCVC.pushVCType = VCPushTypeOfHome;
        QRCVC.edit = ^(BOOL editFlag) {
            
        };
        QRCVC.hidesBottomBarWhenPushed = YES;
        [self.navigationController pushViewController:QRCVC animated:YES];
    } else {
        [UIToolsControl presentSignin:self callBack:^(BOOL signinFlag) {
            
        }];
    }
}
- (void)dropDownViewTapBack {
    self.noDataView.hidden = YES;
    [self.jobTableView setContentOffset:CGPointMake(0, 325*Scale) animated:YES];
}
- (NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section {
    if (itemDataArray.count) {
        return itemDataArray.count;
    }
    return 0;
}
- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath {
    WorkerCell *cell = [tableView dequeueReusableCellWithIdentifier:isCellID];
    if (!cell) {
        cell = [[WorkerCell alloc] initWithStyle:UITableViewCellStyleDefault reuseIdentifier:isCellID];
    }
    
    WorkerModel *model = itemDataArray[indexPath.row];
    [cell reloadDataModel:model];

    return cell;
}
- (void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath {
    [tableView deselectRowAtIndexPath:indexPath animated:YES];
    if ([DataToolsControl sharedManager].validJob) {
        WorkerModel *model = itemDataArray[indexPath.row];
        WorkerResumeDetailViewController *WRDVC = [[WorkerResumeDetailViewController alloc] init];
        WRDVC.job_id = job_id;
        WRDVC.job_cn = job_title;
        WRDVC.id = model.id;
        WRDVC.showChatSettingFlag = NO;
        WRDVC.hidesBottomBarWhenPushed = YES;
        [self.navigationController pushViewController:WRDVC animated:YES];
    } else {
        [self jumpCompanyAudit];
    }
}
- (CGFloat)tableView:(UITableView *)tableView heightForRowAtIndexPath:(NSIndexPath *)indexPath {
    WorkerModel *model = itemDataArray[indexPath.row];
    NSInteger avatar = [model.auth_info[@"avatar"] integerValue];
    NSInteger realname = [model.auth_info[@"realname"] integerValue];
    NSInteger education = [model.auth_info[@"education"] integerValue];
    NSInteger work = [model.auth_info[@"work"] integerValue];
    if (avatar == 1 || realname == 1 || education == 1 || work == 1) {
        return (144-36)*Scale + 25*Scale;
    }
    return (144-36)*Scale;
}
- (CGFloat)tableView:(UITableView *)tableView heightForHeaderInSection:(NSInteger)section {
    return 0.00001;
}
- (CGFloat)tableView:(UITableView *)tableView heightForFooterInSection:(NSInteger)section {
    return 0.00001;
}

- (void)homeCustomNavigationBarViewCity {
    NSLog(@"city");
    SelcetCityViewController *SCVC = [[SelcetCityViewController alloc] init];
    SCVC.hidesBottomBarWhenPushed = YES;
    SCVC.delegate = self;
    [self.navigationController pushViewController:SCVC animated:YES];
}
- (void)selcetCityViewControllerInfo:(NSDictionary *)dic {
    if (district && (![district isEqualToString:[NSString stringWithFormat:@"%@", dic[@"cityid"]]])) {
        [itemDataArray removeAllObjects];
    }
    if ([[NSString stringWithFormat:@"%@", dic[@"cityid"]] integerValue] == 0) {
        district = [NSString stringWithFormat:@"%@", dic[@"provinceid"]];
        navigationBar.city = dic[@"province"];
    } else {
        district = [NSString stringWithFormat:@"%@", dic[@"cityid"]];
        navigationBar.city = dic[@"city"];
    }
    currentPage = 1;
    [self getCompanyList];
//    [NSString stringWithFormat:@"%@-%@-%@", dic[@"province"], dic[@"city"], dic[@"area"]];
}
- (void)homeCustomNavigationBarViewSearch {
    NSLog(@"search");
    if (job_id && job_id.length) {
        SearchWorkerViewController *SWVC = [[SearchWorkerViewController alloc] init];
        SWVC.hidesBottomBarWhenPushed = YES;
        [self.navigationController pushViewController:SWVC animated:YES];
    } else {
        [self jumpCompanyAudit];
    }
}
- (void)jumpCompanyAudit {
    CustomView *alertView = [[CustomView alloc] initWithTitle:@"提示" message:@"您当前没有“审核通过”的职位，去发布职位" prompt:nil sureBtn:@"发布职位" cancleBtn:@"取消" size:170];
    alertView.resultIndex = ^(NSInteger index){
        //回调---处理一系列动作
        if (index == 2) {
            [self gotoCreatJob];
        }
    };
    [alertView showXLAlertView];
}
- (void)companyHomeHeaderViewBannerCarouselTap:(NSString *)temp {
    NSLog(@"%@", temp);
}
- (void)companyHomeHeaderViewNewCarouselTap:(ArticleItemModel *)model {
    NSLog(@"new轮播");
    if (model && model.url) {
        GeneralWebViewViewController *GWVC = [[GeneralWebViewViewController alloc] init];
        GWVC.url = model.url;
        GWVC.showType = GeneralWebViewTypeOfNews;
        GWVC.hidesBottomBarWhenPushed = YES;
        [self.navigationController pushViewController:GWVC animated:YES];
    }
}
- (void)companyHomeHeaderViewNewInvitationTap {
    GeneralWebViewViewController *GWVC = [[GeneralWebViewViewController alloc] init];
    GWVC.showType = GeneralWebViewTypeOfInviteFriend;
    GWVC.hidesBottomBarWhenPushed = YES;
    [self.navigationController pushViewController:GWVC animated:YES];
}
- (void)companyHomeHeaderViewSelectJobTap {
    if ([DataToolsControl sharedManager].validJob) {
        SelectJobViewController *SJVC = [[SelectJobViewController alloc] init];
        __weak __typeof(self)weakSelf = self;
        SJVC.select = ^(NSString *jobId, NSString *jobTitle) {
            __strong __typeof(weakSelf)strongSelf = weakSelf;
            if (jobId && jobId.length) {
                self->job_id = jobId;
                self->job_title = jobTitle;
                [self->tableViewHeaderView reloadDataForJob:jobTitle];
                self->currentPage = 1;
                [self->itemDataArray removeAllObjects];
                [strongSelf getCompanyList];
            }
        };
        SJVC.hidesBottomBarWhenPushed = YES;
        [self.navigationController pushViewController:SJVC animated:YES];
    } else {
        [self jumpCompanyAudit];
    }
}
- (void)scrollViewDidScroll:(UIScrollView *)scrollView {
    if (scrollView == self.jobTableView) {
        navigationBar.offsetY = scrollView.contentOffset.y;
        offsetY = scrollView.contentOffset.y;
    }
}
- (void)recomdendItemTap:(PublicCategoryElementModel *)model {
    [dropView hiddenDropDownViewIndex:0];
    [self hiddenNoDataView];
    NSLog(@"--%@", model.name);
    if (recommend && (![recommend isEqualToString:model.id])) {
        [itemDataArray removeAllObjects];
    }
    recommend = model.id;
    currentPage = 1;
    [self getCompanyList];
}
- (void)areaItemTap:(NSDictionary *)dic {
    [dropView hiddenDropDownViewIndex:1];
    [self hiddenNoDataView];
    if (dic && dic.allKeys.count) {
        NSString *str = [NSString stringWithFormat:@"%@%@-%@%@-%@%@", dic[@"province"], dic[@"provinceid"], dic[@"city"], dic[@"cityid"], dic[@"area"], dic[@"areaid"]];
        NSLog(@"%@", str);
        if (district && (![district isEqualToString:[NSString stringWithFormat:@"%@", dic[@"cityid"]]])) {
            [itemDataArray removeAllObjects];
        }
        if ([[NSString stringWithFormat:@"%@", dic[@"cityid"]] integerValue] == 0) {
            district = [NSString stringWithFormat:@"%@", dic[@"provinceid"]];
            navigationBar.city = dic[@"province"];
        } else {
            district = [NSString stringWithFormat:@"%@", dic[@"cityid"]];
            navigationBar.city = dic[@"city"];
        }
        currentPage = 1;
        [self getCompanyList];
    }
}
- (void)companyItemTap:(NSArray<PublicCategoryElementModel *> *)array {
    [dropView hiddenDropDownViewIndex:2];
    [self hiddenNoDataView];
    if (array.count) {
        NSString *str = @"";
        for (PublicCategoryElementModel *model in array) {
            str = [NSString stringWithFormat:@"%@-%@", str, model.name];
            if ([model.titleName isEqualToString:@"经验"]) {
                if (experience && (![experience isEqualToString:model.id])) {
                    [itemDataArray removeAllObjects];
                }
                experience = model.id;
            }
        }
        if (itemDataArray.count) {
            
        } else {
            currentPage = 1;
            [self getCompanyList];
        }
        NSLog(@"%@", str);
    } else {
        if (experience.length) {
            experience = @"";
            currentPage = 1;
            [self getCompanyList];
        }
    }
}
- (void)claimItemTap:(NSArray<PublicCategoryElementModel *> *)array {
    [dropView hiddenDropDownViewIndex:3];
    [self hiddenNoDataView];
    if (array.count) {
        NSString *str = @"";
        for (PublicCategoryElementModel *model in array) {
            str = [NSString stringWithFormat:@"%@-%@", str, model.name];
            if ([model.titleName isEqualToString:@"薪资"]) {
                if (wage && (![wage isEqualToString:model.id])) {
                    [itemDataArray removeAllObjects];
                }
                wage = model.id;
//                maxwage = model.id;
//                [self getCompanyList];
            } else if ([model.titleName isEqualToString:@"学历"]) {
                if (education && (![education isEqualToString:model.id])) {
                    [itemDataArray removeAllObjects];
                }
                education = model.id;
            } else if ([model.titleName isEqualToString:@"求职状态"]) {
                if (nature && (![nature isEqualToString:model.id])) {
                    [itemDataArray removeAllObjects];
                }
                nature = model.id;
            }
        }
        if (itemDataArray.count) {
            
        } else {
            currentPage = 1;
            [self getCompanyList];
        }
        NSLog(@"%@", str);
    } else {
        if (education.length || wage.length || nature.length) {
            education = @"";
            wage = @"";
            nature = @"";
            currentPage = 1;
            [self getCompanyList];
        }
    }
}
- (void)hiddenNoDataView {
    if (itemDataArray.count) {
        self.noDataView.hidden = YES;
    } else {
        self.noDataView.hidden = NO;
    }
}
- (void)loadDataForJobList {
    self.noDataView.hidden = YES;
    NSMutableDictionary *dic = [NSMutableDictionary dictionaryWithCapacity:0];
    dic = [UIToolsControl getPublicParameter];
    [dic setObject:@"1" forKey:@"status"];
    [dic setObject:@"1" forKey:@"page"];
    [dic setObject:@"1" forKey:@"number"];
    
    [BaseNetManager requestWithMethod:POST path:Company_GetJob_Lists_URL params:dic successBlock:^(NSDictionary * _Nonnull responseObject) {
        if ([responseObject[@"code"] integerValue] == 2000) {
            id data = responseObject[@"data"];
            if ([data isKindOfClass:[NSArray class]]) {
                if ([data count]) {
                    [DataToolsControl sharedManager].validJob = YES;
                    NSDictionary *dicc = data[0];
                    CompanyJobModel *model = [[CompanyJobModel alloc] init];
                    [model setValuesForKeysWithDictionary:dicc];
                    self->job_id = model.id;
                    self->job_title = model.title;
                    
                    [self initUI];
                    [self getCompanyList];
                } else {
                    [DataToolsControl sharedManager].validJob = NO;
                    self->job_id = @"";
                    self->job_title = @"";
                    
                    [self initUI];
                    [self getCompanyList];
                }
            } else {
                [DataToolsControl sharedManager].validJob = NO;
                self->job_id = @"";
                self->job_title = @"";
                
                [self initUI];
                [self getCompanyList];
            }
        } else {
            [DataToolsControl sharedManager].validJob = NO;
            self->job_id = @"";
            self->job_title = @"";
            
            [self initUI];
            [self getCompanyList];
        }
    } failurBlock:^(NSError * _Nonnull error) {
        [self.noDataView vcNilStatusType:VCNilStatusTypeOfNoNet superView:self.view];
    }];
}
- (void)baseInitUI {
    if (!baseBgView) {
        baseBgView = [UIToolsControl initViewWithFrame:CGRectMake(0, HeightOfStatusBarAndNavigationBar, WIDTH, HEIGHT) backgroundColor:COLOR_OF_WHITE];
        [self.view addSubview:baseBgView];
        
        UILabel *topLbl = [UIToolsControl initLabelWithFrame:CGRectMake(0, 100*Scale, WIDTH, 40*Scale) text:@"您未完成企业认证，不能查看人才" textColor:THEMECOLOR_OF_TEXT_333333 font:Font_21];
        topLbl.textAlignment = NSTextAlignmentCenter;
        [baseBgView addSubview:topLbl];
        
        UIImageView *imgView = [UIToolsControl initImageViewWithFrame:CGRectMake(110*Scale, EndY(topLbl)+40*Scale, WIDTH-220*Scale, 120*Scale) imageName:@"qiyerenzheng-panduan"];
        [baseBgView addSubview:imgView];
        
        UILabel *bottomLbl = [UIToolsControl initLabelWithFrame:CGRectMake(0, EndY(imgView), WIDTH, 45*Scale) text:@"企业公司营业执照" textColor:THEMECOLOR_OF_TEXT_9a9a9a font:Font_13];
        bottomLbl.textAlignment = NSTextAlignmentCenter;
        [baseBgView addSubview:bottomLbl];
        
        UIButton *gotoBtn = [UIToolsControl initButtonWithFrame:CGRectMake(40*Scale, EndY(bottomLbl)+30*Scale, WIDTH-80*Scale, 50*Scale) imageName:nil target:self action:@selector(gotoBtnTap) title:@"立刻去完善认证" titleColor:COLOR_OF_WHITE];
        gotoBtn.layer.cornerRadius = 25*Scale;
        gotoBtn.layer.masksToBounds = YES;
        gotoBtn.backgroundColor = THEMECOLOR_OF_ORANGE;
        [baseBgView addSubview:gotoBtn];
    }
}
- (void)gotoBtnTap {
    if (Signin) {
        UITabBarController *tabBarController = (UITabBarController *)[UIApplication sharedApplication].keyWindow.rootViewController;
        tabBarController.selectedIndex = tabBarController.viewControllers.count-1;
        UINavigationController *navigationController = (UINavigationController *)tabBarController.selectedViewController;
        CompanyInfoViewController *CIVC = [[CompanyInfoViewController alloc] init];
        CIVC.hidesBottomBarWhenPushed = YES;
        [navigationController pushViewController:CIVC animated:NO];
    } else {
        [UIToolsControl presentSignin:self callBack:^(BOOL signinFlag) {
            
        }];
    }
}
- (void)gotoCreatJob {
    if (Signin) {
        UITabBarController *tabBarController = (UITabBarController *)[UIApplication sharedApplication].keyWindow.rootViewController;
        tabBarController.selectedIndex = 1;
//        UINavigationController *navigationController = (UINavigationController *)tabBarController.selectedViewController;
//        CompanyInfoViewController *CIVC = [[CompanyInfoViewController alloc] init];
//        CIVC.hidesBottomBarWhenPushed = YES;
//        [navigationController pushViewController:CIVC animated:NO];
    } else {
        [UIToolsControl presentSignin:self callBack:^(BOOL signinFlag) {
            
        }];
    }
}
- (void)loadLocalData {
    recomendDataArray = [NSMutableArray arrayWithCapacity:0];
    areaDataArray = [NSMutableArray arrayWithCapacity:0];
    companyDataArray = [NSMutableArray arrayWithCapacity:0];
    claimDataArray = [NSMutableArray arrayWithCapacity:0];
    
    NSArray *recomendArr = @[@{@"name":@"推荐",
                               @"id":@"1"},
                             @{@"name":@"最新",
                               @"id":@"0"}];
    for (NSInteger i = 0; i < recomendArr.count; i++) {
        PublicCategoryElementModel *model = [[PublicCategoryElementModel alloc] init];
        [model setValuesForKeysWithDictionary:recomendArr[i]];
        [recomendDataArray addObject:model];
    }
    
    NSArray *areaArr = @[@{@"name":@"附近",
                           @"id":@"0",
                           @"child":@[@{@"name":@"距离不限",
                                        @"id":@"0"},
                                      @{@"name":@"1公里",
                                        @"id":@"0"},
                                      @{@"name":@"3公里",
                                        @"id":@"0"}]},
                         @{@"name":@"商圈",
                           @"id":@"0",
                           @"child":@[@{@"name":@"海淀区",
                                        @"id":@"0"},
                                      @{@"name":@"朝阳区",
                                        @"id":@"0"},
                                      @{@"name":@"通州区",
                                        @"id":@"0"}]}];
    for (NSInteger i = 0; i < areaArr.count; i++) {
        PublicCategoryElementModel *model = [[PublicCategoryElementModel alloc] init];
        [model setValuesForKeysWithDictionary:areaArr[i]];
        [areaDataArray addObject:model];
    }
    
    if ([DataToolsControl sharedManager].allCategoryInfoModel) {
        PublicCategoryElementModel *companyModel1 = [[PublicCategoryElementModel alloc] init];
        companyModel1.name = @"工作经验";
        companyModel1.id = @"1";
        companyModel1.childArray = [NSMutableArray arrayWithCapacity:0];
        PublicCategoryElementModel *mmodel111 = [[PublicCategoryElementModel alloc] init];
        mmodel111.id = @"0";
        mmodel111.name = @"不限";
        mmodel111.titleName = @"工作经验";
        [companyModel1.childArray addObject:mmodel111];
        for (NSInteger i = 0; i < [DataToolsControl sharedManager].allCategoryInfoModel.experienceArray.count; i++) {
            PublicCategoryElementModel *mmodel1 = [[DataToolsControl sharedManager].allCategoryInfoModel.experienceArray[i] copy];
            mmodel1.titleName = @"工作经验";
            [companyModel1.childArray addObject:mmodel1];
        }
        [companyDataArray addObject:companyModel1];
        
        
        PublicCategoryElementModel *claimModel1 = [[PublicCategoryElementModel alloc] init];
        claimModel1.name = @"薪资";
        claimModel1.id = @"4";
        claimModel1.childArray = [NSMutableArray arrayWithCapacity:0];
        PublicCategoryElementModel *mmodel222 = [[PublicCategoryElementModel alloc] init];
        mmodel222.id = @"0";
        mmodel222.name = @"不限";
        mmodel222.titleName = @"薪资";
        [claimModel1.childArray addObject:mmodel222];
        for (NSInteger i = 0; i < [DataToolsControl sharedManager].allCategoryInfoModel.wageArray.count; i++) {
            PublicCategoryElementModel *mmodel2 = [[DataToolsControl sharedManager].allCategoryInfoModel.wageArray[i] copy];
            mmodel2.titleName = @"薪资";
            [claimModel1.childArray addObject:mmodel2];
        }
        [claimDataArray addObject:claimModel1];
        
        PublicCategoryElementModel *education1 = [[PublicCategoryElementModel alloc] init];
        education1.name = @"学历";
        education1.id = @"5";
        education1.childArray = [NSMutableArray arrayWithCapacity:0];
        PublicCategoryElementModel *mmodel333 = [[PublicCategoryElementModel alloc] init];
        mmodel333.id = @"0";
        mmodel333.name = @"不限";
        mmodel333.titleName = @"学历";
        [education1.childArray addObject:mmodel333];
        for (NSInteger i = 0; i < [DataToolsControl sharedManager].allCategoryInfoModel.educationArray.count; i++) {
            PublicCategoryElementModel *mmodel3 = [[DataToolsControl sharedManager].allCategoryInfoModel.educationArray[i] copy];
            mmodel3.titleName = @"学历";
            [education1.childArray addObject:mmodel3];
        }
        [claimDataArray addObject:education1];
        
        PublicCategoryElementModel *current1 = [[PublicCategoryElementModel alloc] init];
        current1.name = @"求职状态";
        current1.id = @"5";
        current1.childArray = [NSMutableArray arrayWithCapacity:0];
        PublicCategoryElementModel *mmodel444 = [[PublicCategoryElementModel alloc] init];
        mmodel444.id = @"0";
        mmodel444.name = @"不限";
        mmodel444.titleName = @"求职状态";
        [current1.childArray addObject:mmodel444];
        for (NSInteger i = 0; i < [DataToolsControl sharedManager].allCategoryInfoModel.currentArray.count; i++) {
            PublicCategoryElementModel *mmodel4 = [[DataToolsControl sharedManager].allCategoryInfoModel.currentArray[i] copy];
            mmodel4.titleName = @"求职状态";
            [current1.childArray addObject:mmodel4];
        }
        [claimDataArray addObject:current1];
    }
}

@end
*/
